sequenceDiagram
    title 服务购买-订单申请退款

    autonumber

    actor User as 用户
    participant DealerServicePurchaseOrderApplicationService
    participant DealerServicePurchaseOrderRepository
    participant DealerServicePurchaseOrder
    participant DomainEventPublisher


    User->>DealerServicePurchaseOrderApplicationService: requestRefund()

    activate DealerServicePurchaseOrderApplicationService

    DealerServicePurchaseOrderApplicationService->>DealerServicePurchaseOrderRepository: findById(DealerServicePurchaseOrderId)

    activate DealerServicePurchaseOrderRepository
    DealerServicePurchaseOrderRepository-->>DealerServicePurchaseOrderApplicationService: DealerServicePurchaseOrder
    deactivate DealerServicePurchaseOrderRepository

    DealerServicePurchaseOrderApplicationService->>DealerServicePurchaseOrder: requestRefund()

    activate DealerServicePurchaseOrder
    DealerServicePurchaseOrder->>DealerServicePurchaseOrder: 验证是否可以发起退款
    DealerServicePurchaseOrder->>DealerServicePurchaseOrder: 更新内部数据状态
    DealerServicePurchaseOrder->>DomainEventPublisher: 发布领域事件 RefundRequested

    deactivate DealerServicePurchaseOrder

    DealerServicePurchaseOrderApplicationService->>DealerServicePurchaseOrderRepository: save(DealerServicePurchaseOrder)

    deactivate DealerServicePurchaseOrderApplicationService